package com.yinian.server.service.impl;


import com.yinian.pojo.dto.TeachDetailDTO;
import com.yinian.pojo.entity.App;
import com.yinian.pojo.entity.AppModule;
import com.yinian.pojo.entity.TeachDetail;
import com.yinian.server.mapper.TeachMapper;
import com.yinian.server.service.TeachService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Slf4j
@Service
public class TeachServiceImpl implements TeachService {

    @Autowired
    private TeachMapper teachMapper;


    @Override
    public List<App> getApp() {
        return teachMapper.getApp();
    }

    @Override
    public TeachDetailDTO getTeachDetail(long moduleId,String moduleTableName) {
        String detailTableName = teachMapper.getDetailTableNameByModuleId(moduleId,moduleTableName);
        log.info("detailTableName:{}", detailTableName);
        TeachDetail teachDetail =   teachMapper.getDetailByModuleId(detailTableName,moduleId);
        log.info("teachDetail:{}", teachDetail);
        String stepTableName = teachDetail.getTableName();
        return teachMapper.getAllTeachDetail(detailTableName,stepTableName,moduleId);
    }


    @Override
    public List<AppModule> getAppModule(long appId) {
        String tableName = teachMapper.getTableNameByAppId(appId);
        log.info("tableName:{}", tableName);
        return teachMapper.getAppModule(tableName);
    }
}
